package com.example.administrator.a0024simpleadapter;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class MainActivity extends AppCompatActivity {
    private ListView listView;
    private SimpleAdapter simpleAdapter;
    private ArrayList<Map<String,Object>> data;
    private Map<String,Object> map;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        listView = findViewById(R.id.listView);

        data = new ArrayList<Map<String,Object>>();
        for ( int i=0;i<40;i++ ){
            map = new HashMap<String, Object>();
            map.put("data","标题"+i);
            map.put("intro","简介"+i);
            data.add(map);
        }
        String[] from = {"data","intro"};
        int[] to = {R.id.data,R.id.intro};


        simpleAdapter =new SimpleAdapter(MainActivity.this,data,R.layout.simpleadapter_item,from,to);

        listView.setAdapter(simpleAdapter);



    }
}
